import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:wis_flutter/index.dart';

// 查询页
class SearchPage extends StatefulWidget {
  // final String title;
  final String label;
  final List data;
  final dynamic filterData; // 过滤数据
  final dynamic defaultClickConfig; // 默认按钮配置

  final dynamic headPopupMenu; // 头部按钮
  final dynamic onSearch;
  final dynamic onRowClick; // 行点击事件
  final dynamic onFilter; // 筛选点击
  final dynamic onHeadChange; // 头部按钮切换
  final dynamic onRefreshPullUp; // 上拉刷新
  final dynamic onRefresh; // 下拉刷新
  final bool singleChoice; // 单选
  final bool checkbox; // 复选框
  final dynamic onselectAll; // checkbox 选中回调
  final dynamic htmlPage; // 自定义页面
  final dynamic customButton; // 自定义按钮
  final dynamic onLoadingmore; // 加载更多
  final bool hideLoadingmore; // 隐藏加载更多

  SearchPage({
    Key key,
    this.label,
    this.data,
    this.filterData,
    this.defaultClickConfig,
    this.headPopupMenu,
    this.onSearch,
    this.onRowClick,
    this.onFilter,
    this.onHeadChange,
    this.onRefreshPullUp,
    this.onRefresh,
    this.singleChoice = false,
    this.checkbox = false,
    this.onselectAll,
    this.htmlPage,
    this.customButton,
    this.onLoadingmore,
    this.hideLoadingmore = false,
  }) : super(key: key);

  @override
  _SearchPageState createState() => new _SearchPageState();
}

class _SearchPageState extends State<SearchPage> {
  bool dialogHtmlActive = false;
  bool loadingmoreAction = false; // 加载更多
  OverlayEntry overlayEntry;
  LayerLink layerLink = new LayerLink();

  bool isDrawer = false; // 打开侧栏
  String headPopupValue = ""; // 头部按钮默认显示值
  bool isPerformingRequest = false; // 是否有请求正在进行

  ScrollController _scrollController = new ScrollController();

  final _formKey = GlobalKey<FormState>();
  TextEditingController _valueController = TextEditingController(); // 查询内容

  // 初始化
  @override
  void initState() {
    super.initState();

    this._setheadPopupValue();

    // 上拉刷新
    _scrollController.addListener(() {
      if (_scrollController.position.pixels ==
          _scrollController.position.maxScrollExtent) {
        this._getMoreData();
      }
    });
  }

  @override
  void dispose() {
    _scrollController.dispose();
    super.dispose();
  }

  // 设置头部按钮 选中值
  void _setheadPopupValue() {
    if (widget.headPopupMenu != null) {
      setState(() {
        headPopupValue = widget.headPopupMenu[0]["label"];
      });
    }
  }

  // 查询
  void _onSearch() {
    //读取当前的Form状态
    var loginForm = _formKey.currentState;

    // //验证Form表单
    if (loginForm.validate()) {
      // 回调
      if (widget.onSearch != null) {
        widget.onSearch({
          "value": _valueController.text,
        });
      }
    }
  }

  // 头部按钮切换
  void _onHeadChange(option) {
    if (widget.onRowClick != null) {
      widget.onHeadChange(option);
    }
  }

  // 点击行
  void _onRowClick(option) {
    if (widget.onRowClick != null) {
      widget.onRowClick(option);
    }

    setState(() {
      isDrawer = false;
    });
  }

  // 筛选点击
  void _onFilter() {
    if (widget.onFilter != null) {
      List _newList = [];

      for (var i = 0; i < widget.filterData.length; i++) {
        var item = jsonDecode(jsonEncode(widget.filterData[i]));
        List child = [];

        for (var k = 0; k < item["children"].length; k++) {
          if (item["children"][k]["_check"] == true) {
            child.add(item["children"][k]);
          }
        }

        // print(child);
        item["children"] = child;
        if (child.length >= 1) {
          _newList.add(item);
        }
      }

      // print(_newList);
      widget.onFilter(_newList);
    }

    setState(() {
      isDrawer = false;
    });
  }

  // 筛选选中
  void _onSelectFilter(option, item, val) {
    for (var i = 0; i < widget.filterData.length; i++) {
      var parent = widget.filterData[i];
      if (parent['type'] == option['type']) {
        for (var j = 0; j < parent['children'].length; j++) {
          var child = parent['children'][j];

          if (parent['multiple'] == false) child['_check'] = false;
          if (child['id'] == item['id']) {
            // var result=(child['_check']!=null)?child['_check']:false;
            child['_check'] = val;
          }
        }
      }
    }

    setState(() {});
  }

  // 筛选遍历
  Widget _bodyInit(option) {
    List<Widget> tiles = [];

    // Widget content;
    for (var item in option["children"]) {
      tiles.add(Padding(
          padding: const EdgeInsets.fromLTRB(8, 0, 0, 0),
          child: Row(children: <Widget>[
            Container(
                width: 38,
                height: 36,
                child: Checkbox(
                  value: (item['_check'] != null) ? item['_check'] : false,
                  activeColor: Colors.blue,
                  onChanged: (bool val) {
                    this._onSelectFilter(option, item, val);
                  },
                )),
            Padding(
                padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
                child: Container(
                    width: 180,
                    height: 36,
                    child: Text(item['value'],
                        textAlign: TextAlign.left,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                          color: const Color.fromRGBO(81, 90, 110, 1),
                          fontSize: 14.0,
                          height: 2.1,
                        ))))
          ])));
    }

    return Column(
      children: tiles.toList(),
    );
  }

  // 遍历 头部按钮
  _getPopupMenu(BuildContext context) {
    List<PopupMenuEntry<String>> _list = [];

    if (widget.headPopupMenu != null) {
      for (var i = 0; i < widget.headPopupMenu.length; i++) {
        _list.add(
          PopupMenuItem<String>(
            value: widget.headPopupMenu[i]["value"],
            child: Text(widget.headPopupMenu[i]["label"].toString()),
          ),
        );
      }

      return _list;
    }

    return _list;
  }

  // 上拉刷新
  _getMoreData() async {
    if (!isPerformingRequest) {
      setState(() => isPerformingRequest = true);

      if (widget.onRefreshPullUp != null) {
        var resule = await widget.onRefreshPullUp();

        // 防止重复刷新
        if (resule == true) {
          setState(() => isPerformingRequest = false);
        }
      }
    }
  }

  // 下拉 刷新
  Future<Null> _onRefresh() async {
    if (widget.onRefresh != null) {
      await widget.onRefresh();
    }
  }

  // 内容显示 循环
  Widget _contentList(option) {
    if (option["children"] != null) {
      List<Widget> list = [];

      for (var item in option["children"]) {
        list.add(Container(
            padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(width: 1, color: Color(0xffe5e5e5)))),
            child: Row(
              children: <Widget>[
                Expanded(
                    flex: 3,
                    child: Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 26, 0),
                      child: Text(item["label"].toString()),
                    )),
                Expanded(
                    flex: 3,
                    child: Text(item["value"] != null ? item["value"] : ''))
              ],
            )));
      }

      return Column(
        children: list.toList(),
      );
    }

    return null;
  }

  // 自定义 按钮
  Widget _customBtnInit(option) {
    if (option["buttonList"] != null) {
      List<Widget> _list = [];

      // Widget content;
      for (var item in option["buttonList"]) {
        _list.add(Container(
            margin: EdgeInsets.fromLTRB(0, 2, 0, 2),
            padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
            height: 28,
            child: RaisedButton(
              textTheme: ButtonTextTheme.accent,
              color: item["icon"] != null ? item["icon"] : Colors.blue[500],
              padding: EdgeInsets.fromLTRB(8, 2, 8, 2),
              onPressed: () {
                if (item["onClick"] != null) {
                  item["onClick"](item);
                }
              },
              child: Text(
                item["label"] != null ? item["label"].toString() : "",
                style: TextStyle(color: Colors.white, fontSize: 14),
              ),
            )));
      }

      return Wrap(
        children: _list.toList(),
      );
    }

    return null;
  }

  // checkBox change
  void changeRowCheckbox(index, val) {
    if (widget.singleChoice) {
      for (var k = 0; k < widget.data.length; k++) {
        widget.data[k]["_check"] = false;
      }
    }

    widget.data[index]["_check"] = val;

    setState(() {});

    // 回调
    if (widget.onselectAll != null) {
      List _nowlist = [];
      for (var j = 0; j < widget.data.length; j++) {
        if (widget.data[j]["_check"] != null &&
            widget.data[j]["_check"] == true) {
          _nowlist.add(widget.data[j]);
        }
      }

      widget.onselectAll(_nowlist);
    }
  }

  // 打开 自定义 页面
  void _onDialog3(context) {
    if (this.dialogHtmlActive == false) {
      overlayEntry = createSelectPopupWindow();
      Overlay.of(context).insert(overlayEntry);
      FocusScope.of(context).requestFocus(FocusNode());
    }

    setState(() {
      dialogHtmlActive = true;
    });
  }

  // 关闭 自定义弹框
  void _removeOverlayEntry() {
    if (this.dialogHtmlActive == true) {
      overlayEntry.remove();
    }

    setState(() {
      dialogHtmlActive = false;
    });
  }

  // 自定义 页面
  // 创建 弹框
  OverlayEntry createSelectPopupWindow() {
    OverlayEntry overlayEntry = OverlayEntry(builder: (context) {
      final size = MediaQuery.of(context).size;

      return Positioned(
        width: size.width * 1,
        height: size.height,
        child: CompositedTransformFollower(
          offset: Offset(0.0, 50),
          link: layerLink,
          child: Material(
            child: Container(
                padding: const EdgeInsets.fromLTRB(12, 36, 12, 20),
                color: Colors.white,
                child: Stack(children: <Widget>[
                  // 标题
                  Container(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 8,
                            child: Text(
                              widget.htmlPage["title"] != null
                                  ? widget.htmlPage["title"]
                                  : '',
                              style: TextStyle(
                                  color: const Color.fromRGBO(81, 90, 110, 1),
                                  fontWeight: FontWeight.w700,
                                  fontSize: 16),
                            )),
                        Expanded(
                            flex: 1,
                            child: IconButton(
                                icon: Icon(
                                  Icons.highlight_off,
                                  color: Color.fromARGB(255, 126, 126, 126),
                                ),
                                onPressed: () {
                                  this._removeOverlayEntry();
                                })),
                      ],
                    ),
                  ),

                  Container(
                    padding: const EdgeInsets.fromLTRB(0, 36, 0, 20),
                    child: widget.htmlPage["child"],
                  ),

                  // 筛选
                  Positioned(
                      bottom: 55.0,
                      right: 30.0,
                      child: Container(
                          height: 60,
                          width: 60,
                          child: (widget.htmlPage != null &&
                                  widget.htmlPage["onsubmit"] != null)
                              ? RaisedButton(
                                  shape: RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(50)),
                                  child: Text('提交'),
                                  color: Colors.blue,
                                  textColor: Colors.white,
                                  elevation: 20,
                                  onPressed: () {
                                    if (widget.htmlPage["onsubmit"] != null) {
                                      widget.htmlPage["onsubmit"]();
                                    }
                                  },
                                )
                              : null))
                ])),
          ),
        ),
      );
    });
    return overlayEntry;
  }

  // 加载 更多
  void _loadingmore() async {
    if (widget.onLoadingmore != null) {
      setState(() {
        loadingmoreAction = true;
      });

      var result = await widget.onLoadingmore();

      if (result == true) {
        setState(() {
          loadingmoreAction = false;
        });
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: () {
          setState(() {
            isDrawer = false;
          });
        },
        child: Stack(
          children: <Widget>[
            Container(
              padding: const EdgeInsets.fromLTRB(0, 32, 0, 0),
              child: widget.headPopupMenu != null
                  ? PopupMenuButton(
                      child: Container(
                        width: 78,
                        margin: const EdgeInsets.fromLTRB(8, 8, 8, 8),
                        child: Row(
                          children: <Widget>[
                            Container(
                              width: 50,
                              child: Text(
                                headPopupValue,
                                overflow: TextOverflow.ellipsis,
                              ),
                            ),
                            Icon(Icons.arrow_drop_down)
                          ],
                        ),
                        decoration: BoxDecoration(
                            border: Border(
                                bottom:
                                    BorderSide(width: 2, color: Colors.blue))),
                      ),
                      onSelected: (value) {
                        for (var i = 0; i < widget.headPopupMenu.length; i++) {
                          if (widget.headPopupMenu[i]['value'] == value) {
                            setState(() {
                              headPopupValue = widget.headPopupMenu[i]["label"];
                            });
                          }
                        }
                        this._onHeadChange(value);
                      },
                      itemBuilder: (context) => _getPopupMenu(context),
                    )
                  : Text(''),
            ),
            Container(
                padding: const EdgeInsets.fromLTRB(8, 8, 8, 8),
                child: (widget.onSearch != null)
                    ? Form(
                        key: _formKey,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Container(
                                padding: widget.headPopupMenu != null
                                    ? const EdgeInsets.fromLTRB(88, 0, 0, 0)
                                    : const EdgeInsets.fromLTRB(0, 0, 0, 0),
                                child: TextFormField(
                                  onTap: () {
                                    setState(() {
                                      isDrawer = false;
                                    });
                                  },
                                  onEditingComplete: () {
                                    this._onSearch();
                                    FocusScope.of(context)
                                        .requestFocus(FocusNode());
                                  },
                                  controller: _valueController,
                                  decoration: InputDecoration(
                                    labelText: widget.label,
                                    labelStyle: TextStyle(
                                        fontSize: 14.0,
                                        color: Color.fromARGB(255, 93, 93, 93)),
                                    enabledBorder: UnderlineInputBorder(
                                      borderSide:
                                          BorderSide(color: Colors.grey),
                                    ),
                                    focusedBorder: UnderlineInputBorder(
                                      borderSide:
                                          BorderSide(color: Colors.blue),
                                    ),
                                    border: InputBorder.none,
                                    suffixIcon: IconButton(
                                        icon: Icon(
                                          Icons.search,
                                          color: Color.fromARGB(
                                              255, 126, 126, 126),
                                        ),
                                        onPressed: () {
                                          this._onSearch();
                                          FocusScope.of(context)
                                              .requestFocus(FocusNode());
                                        }),
                                  ),
                                  // validator: (value) {
                                  //   if (value.isEmpty) {
                                  //     return '内容';
                                  //   }
                                  //   return null;
                                  // },
                                ))
                          ],
                        ),
                      )
                    : Text('')),

            Container(
                margin: (widget.onSearch != null)
                    ? EdgeInsets.fromLTRB(0, 78, 0, 0)
                    : EdgeInsets.fromLTRB(0, 0, 0, 0),
                child: RefreshIndicator(
                  onRefresh: _onRefresh,
                  child: ListView.builder(
                      controller: _scrollController,
                      itemCount: widget.data.length + 1,
                      itemBuilder: (context, index) {
                        // 加载更多
                        if (widget.data.length == index) {
                          return InkWell(
                            onTap: () {
                              // print("aaa");
                              if (widget.hideLoadingmore == false) {
                                this._loadingmore();
                              }
                            },
                            child: Container(
                              child: (widget.hideLoadingmore == false &&
                                      widget.onLoadingmore != null)
                                  ? Container(
                                      // color: Colors.white,
                                      margin: const EdgeInsets.fromLTRB(
                                          0, 10, 0, 50),
                                      padding: const EdgeInsets.fromLTRB(
                                          150, 0, 0, 0),
                                      child: loadingmoreAction == true
                                          ? Row(
                                              children: <Widget>[
                                                Text("正在加载..."),
                                                Image.asset(
                                                  "assets/images/looding1.gif",
                                                  width: 40,
                                                  height: 40,
                                                )
                                              ],
                                            )
                                          : Row(
                                              children: <Widget>[
                                                Text("点击加载更多"),
                                                Icon(Icons.sync)
                                              ],
                                            ))
                                  : WisDivider(
                                      text: "到底了",
                                    ),
                            ),
                          );
                        }

                        return InkWell(
                            onTap: () {
                              this._onRowClick(widget.data[index]);
                            },
                            child: Container(
                                padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
                                decoration: BoxDecoration(
                                    border: Border(
                                        bottom: BorderSide(
                                            width: 1,
                                            color: Color(0xffe5e5e5)))),
                                child: Row(
                                  children: [
                                    Expanded(
                                      flex: 11,
                                      child: Column(
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          Container(
                                            padding:
                                                EdgeInsets.fromLTRB(0, 8, 0, 8),
                                            // color: Colors.blue,
                                            child: (null !=
                                                    widget.data[index]["title"])
                                                ? Row(
                                                    children: <Widget>[
                                                      (widget.checkbox
                                                          ? Expanded(
                                                              child: Checkbox(
                                                              value: (widget.data[
                                                                              index]
                                                                          [
                                                                          '_check'] !=
                                                                      null)
                                                                  ? widget.data[
                                                                          index]
                                                                      ['_check']
                                                                  : false,
                                                              activeColor:
                                                                  Colors.blue,
                                                              onChanged:
                                                                  (bool val) {
                                                                FocusScope.of(
                                                                        context)
                                                                    .requestFocus(
                                                                        FocusNode());
                                                                this.changeRowCheckbox(
                                                                    index, val);
                                                              },
                                                            ))
                                                          : Container(
                                                              child: null)),
                                                      Expanded(
                                                          flex: 11,
                                                          child: Padding(
                                                              padding:
                                                                  EdgeInsets
                                                                      .fromLTRB(
                                                                          6,
                                                                          2,
                                                                          28,
                                                                          2),
                                                              child: Text(
                                                                widget.data[
                                                                        index]
                                                                    ["title"],
                                                                overflow:
                                                                    TextOverflow
                                                                        .ellipsis,
                                                                style:
                                                                    TextStyle(
                                                                  fontWeight:
                                                                      FontWeight
                                                                          .bold,
                                                                ),
                                                              ))),
                                                      Expanded(
                                                          flex: 6,
                                                          child: ((widget.defaultClickConfig !=
                                                                      null) ||
                                                                  (widget.data[
                                                                              index]
                                                                          [
                                                                          "titleBtnText"] !=
                                                                      null))
                                                              ? Row(
                                                                  children: <
                                                                      Widget>[
                                                                    Expanded(
                                                                        flex: 5,
                                                                        child:
                                                                            Text(
                                                                          ((widget.data[index]["titleBtnText"] != null)
                                                                              ? widget.data[index]["titleBtnText"].toString()
                                                                              : widget.defaultClickConfig["text"].toString()),
                                                                          textAlign:
                                                                              TextAlign.right,
                                                                          overflow:
                                                                              TextOverflow.ellipsis,
                                                                          style:
                                                                              TextStyle(color: (widget.data[index]["titleBtnColor"] != null) ? widget.data[index]["titleBtnColor"] : Colors.black87),
                                                                        )),
                                                                    Expanded(
                                                                        flex: 2,
                                                                        child:
                                                                            Icon(
                                                                          widget
                                                                              .defaultClickConfig["icon"],
                                                                          color: Color.fromARGB(
                                                                              255,
                                                                              126,
                                                                              126,
                                                                              126),
                                                                        )),
                                                                  ],
                                                                )
                                                              : Text(""))
                                                    ],
                                                  )
                                                : null,
                                          ),
                                          Container(
                                              child: (null !=
                                                      widget.data[index]
                                                          ["content"])
                                                  ? Text(
                                                      widget.data[index]
                                                          ["content"],
                                                      overflow:
                                                          TextOverflow.ellipsis,
                                                      style: TextStyle(
                                                        color: Colors.grey[500],
                                                      ),
                                                    )
                                                  : null),
                                          Container(
                                              child: _contentList(
                                                  widget.data[index])),
                                          Container(
                                              alignment: Alignment.topRight,
                                              padding: EdgeInsets.fromLTRB(
                                                  0, 6, 0, 0),
                                              child: _customBtnInit(
                                                  widget.data[index]))
                                        ],
                                      ),
                                    ),

                                    // Expanded(
                                    //   flex: 1,
                                    //   child: ( widget.onRowClick !=null ) ? Icon(
                                    //       Icons.chevron_right,
                                    //       color: Color.fromARGB(255, 126, 126, 126),
                                    //   ): Text('')
                                    // )
                                    // Icon(
                                    //   Icons.search,
                                    //   // color: Colors.red[500],
                                    // ),
                                    // new Text('41'),
                                    // Divider(height:20.0),
                                  ],
                                )));
                      }),
                )),

            Container(
                child: (isDrawer)
                    ? InkWell(
                        onTap: () {},
                        child: Drawer(
                            child: Stack(children: <Widget>[
                          Container(
                              // height: 100,
                              margin: EdgeInsets.fromLTRB(0, 8, 16, 0),
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Expanded(
                                    flex: 8,
                                    child: Text(' '),
                                  ),
                                  Expanded(
                                      flex: 1,
                                      child: IconButton(
                                          icon: Icon(
                                            Icons.highlight_off,
                                            color: Color.fromARGB(
                                                255, 126, 126, 126),
                                          ),
                                          onPressed: () {
                                            setState(() {
                                              isDrawer = false;
                                            });
                                            // this._removeOverlayEntry();
                                          }))
                                ],
                              )),
                          Container(
                              margin: EdgeInsets.fromLTRB(0, 42, 26, 0),
                              child: Row(
                                children: <Widget>[
                                  Expanded(
                                    flex: 6,
                                    child: Text(" "),
                                  ),
                                  Expanded(
                                      flex: 2,
                                      child: Container(
                                          child: IconButton(
                                        icon: Icon(
                                          Icons.check,
                                          color: Colors.blue,
                                        ),
                                        onPressed: _onFilter,
                                      )))
                                ],
                              )),
                          Container(
                              margin: EdgeInsets.fromLTRB(0, 72, 0, 0),
                              child: (widget.filterData != null)
                                  ? ListView.builder(
                                      itemCount: widget.filterData.length,
                                      itemBuilder: (context, index) {
                                        return Container(
                                            child: Row(children: [
                                          Stack(children: <Widget>[
                                            Padding(
                                                padding: EdgeInsets.fromLTRB(
                                                    8, 0, 0, 0),
                                                child: Text(
                                                  (widget.filterData[index]
                                                          ['title'])
                                                      .toString(),
                                                  style: TextStyle(
                                                      fontSize: 14,
                                                      fontWeight:
                                                          FontWeight.w600),
                                                )),
                                            Container(
                                                margin: EdgeInsets.fromLTRB(
                                                    10, 30, 0, 18),
                                                child: _bodyInit(
                                                    widget.filterData[index])),
                                            // Divider(height:20.0),
                                          ])
                                        ]));
                                      })
                                  : Text("")),
                        ])),
                      )
                    : null),

            Positioned(
                bottom: 55.0,
                left: 10.0,
                child: Container(
                  child: widget.customButton != null
                      ? ButtonBar(
                          children: widget.customButton,
                        )
                      : null,
                )),

            // 编辑按钮
            Positioned(
                bottom: 130.0,
                right: 30.0,
                child: Container(
                    height: 62,
                    width: 62,
                    child: (widget.htmlPage != null)
                        ? RaisedButton(
                            shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(50)),
                            child: Text('编辑'),
                            color: Colors.blue,
                            textColor: Colors.white,
                            elevation: 20,
                            onPressed: () {
                              this._onDialog3(context);
                            },
                          )
                        : null)),

            // 筛选
            Positioned(
                bottom: 55.0,
                right: 30.0,
                child: (widget.filterData != null)
                    ? Container(
                        height: 62,
                        width: 62,
                        child: RaisedButton(
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(50)),
                          child: Text('筛选'),
                          color: Colors.blue,
                          textColor: Colors.white,
                          elevation: 20,
                          onPressed: () {
                            setState(() {
                              isDrawer = true;
                            });
                          },
                        ))
                    : Text(''))
          ],
        ));
  }
}
